import { reactive } from 'vue';

const formRules = {
  deliverType: [{ required: true, message: '请选择工单类型' }],
  deliverPlanTime: [{ required: true, message: '请选择计划时间' }],
  areaNameStart: [{ required: true, message: '请选择出发地' }],
  areaNameEnd: [{ required: true, message: '请选择目的地' }],
  deliverToolName: [{ required: true, message: '请选择运送工具' }],
};

const formState = reactive<AppWoDeliver.Dto>({
  orderTypeId: '',
  orderTypeCode: '',
  orderTypeName: '',
  orderSubTypeId: '',
  orderSubTypeCode: '',
  orderSubTypeName: '',
  orderSourceId: '',
  orderSourceName: '',
  orderSourceCode: '',
  planTimeStart: 0,
  planTimeEnd: 0,
  areaIdStart: '',
  areaNameStart: '',
  areaIdEnd: '',
  areaNameEnd: '',
  deliverToolId: '',
  deliverToolName: '',
  deliverToolCode: '',
  patientInfo: '',
  description: '',
  woDeliverFileDto: [],
  assignModel: 3,
  status: 'deliver_task_assign',
});

interface DeliverType {
  text: string;
  value: string;
  children: { text: string; value: string }[];
}

const state = reactive<{
  /**
   * 工单子类型列表
   */
  taskTypeList: AppSysDict.Dto[];
  /**
   * 工单子类型列表
   */
  taskSubTypeList: AppSysDict.Dto[];
  /**
   * 工单类型选择器是否显示
   */
  taskTypePickerIsShow: boolean;
  /**
   * 工单计划时间选择器是否显示
   */
  taskTimePickerVisible: boolean;

  /**
   * 区域列表弹出层是否显示
   */
  appRegionListPopupIsShow: boolean;

  /**
   * 运送工单类型列表
   */
  deliverTypeList: DeliverType[];
  /**
   * 运动工单类型
   */
  deliverType: string;
  /**
   * 运动工单计划时间
   */
  deliverPlanTime: string;

  /**
   * 0 没有选择
   * 1 出发地
   * 2 目的地
   */
  currentSelectedArea?: 0 | 1 | 2;

  /**
   * 运动工单类型
   */
  deliverToolList: AppSysDict.Dto[];

  /**
   * 运送工具选择器是否显示
   */
  appDeliverToolListPopupIsShow: boolean;
}>({
  taskTypeList: [],
  taskSubTypeList: [],
  taskTypePickerIsShow: false,
  taskTimePickerVisible: false,
  appRegionListPopupIsShow: false,
  deliverTypeList: [],
  deliverType: '',
  deliverPlanTime: '',
  currentSelectedArea: 0,
  deliverToolList: [],
  appDeliverToolListPopupIsShow: false,
});

export { formState, formRules, state, DeliverType };
